<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="pojo.User" %>
<%@ page import="utils.db.impl.UserFetcher" %>
<%@ page import="java.util.List" %>

<script type="text/javascript" src="js/userChoice.js"></script>
<%
User user=(User)session.getAttribute("user");

%>
<%if (session.getAttribute("user") == null) {%>
<h1>Brak dostępu do tej strony!</h1>
<%}else{ 
%>
<h1>Zarządzanie Użytkownikami</h1>
<div id="gallery_container">
<h3>Zmień typ użytkownika</h3>

<form action="ChangeTypeServlet" method="POST">
<table>
			<tr>
			<td>
				<div class="styled-select">
				<select name="id" id="id">
				<option value="0">Wybierz użytkownika do usunięcia... </option>
				<%
				UserFetcher fetcher = new UserFetcher();
				List<User> users = fetcher.getUsers(); 
				for(int i=0;i<users.size();i++){
				%>
				<option value="<%=users.get(i).getId()%>"><%=users.get(i).getFirstName()%> <%=users.get(i).getLastName()%> - <%=users.get(i).getEmail()%></option>
				<%} %>
				</select>
				</div>
			</td>
			<td>
			<div class="styled-select">
				<select name="type" id="type">
				<option value="0">Wybierz typ... </option>
				<option value="CLIENT">KLIENT </option>
				<option value="SERVICEMAN">SERWISANT</option>
				<option value="ADMIN">ADMINISTRATOR </option>
				</select>
				</div>
			</td>
			</tr>
			<tr>
			<td>
			<input type="submit" id="submit" class="styled-button-3" value="Zmień" />
			</td>
				</tr>
</table>
</form>
													<%
		if (session.getAttribute("warning") != null) {
	%>
	<span><%= session.getAttribute("warning") %></span> 
	<%
		session.removeAttribute("warning");
		}
	%>
	



<br/><br/>

<h3>Usuń użytkownika</h3>

<form action="DeleteUserServlet" method="POST"> 

<table>
<tr>
<td>
<div class="styled-select">
				<select name="delete" id="delete">
				<option value="0">Wybierz użytkownika do usunięcia... </option>
				<%
			
				for(int i=0;i<users.size();i++){
				%>
				<option value="<%=users.get(i).getId()%>"><%=users.get(i).getFirstName()%> <%=users.get(i).getLastName()%> - <%=users.get(i).getEmail()%></option>
				<%} %>	
			</select></div></td>
			
			<td>
				<input type="submit" id="submit" class="styled-button-3" value="Usuń" /></td>
				</tr>
</table>
		<%if (session.getAttribute("delete") != null) {
	%>
	<span><%= session.getAttribute("delete") %></span> 
	<%
		session.removeAttribute("delete");
		}
	%>


	</form>


</div>
<%} %>
